//
//  DHHotRadioTableViewCell.m
//  Moment
//
//  Created by dllo on 15/12/23.
//  Copyright © 2015年 谭泽源. All rights reserved.
//

#import "DHHotRadioTableViewCell.h"

@implementation DHHotRadioTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    _hotRadioArr = [NSMutableArray array];
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createViews];
    }
    return self;
}
-(void)createViews{
    _FirstImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_FirstImageView];
   _secondImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_secondImageView];
    _thirdImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_thirdImageView];
}
-(void)setHotRadioArr:(NSMutableArray *)hotRadioArr{
    if (_hotRadioArr != hotRadioArr) {
        _hotRadioArr = hotRadioArr;
    }
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)];
    
     UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)];
     UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)];
    CGFloat heigth = (SCREEN_WIDTH - 16)/3;
//    NSLog(@"height == %.2f",heigth);
        [_FirstImageView addGestureRecognizer:tap1];
    _FirstImageView.userInteractionEnabled = YES;
    _secondImageView.userInteractionEnabled = YES;

    _thirdImageView.userInteractionEnabled = YES;

    
        [_FirstImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.top.equalTo(@5);
        make.bottom.equalTo(@-5);
        make.width.equalTo(@(heigth));
        make.top.equalTo(@5);
        
    }];
    DHRadio *firstRadio = [[DHRadio alloc]init];
    firstRadio = _hotRadioArr[0];
    NSURL *url = [NSURL URLWithString:firstRadio.coverimg];
    [_FirstImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"zanwei"]];
    _FirstImageView.tag = 10001;
    
    [_secondImageView addGestureRecognizer:tap2];
    
    [_secondImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@5);
        make.left.equalTo(_FirstImageView.mas_right).offset(3);
        make.bottom.equalTo(@-5);
        make.width.equalTo(@(heigth));
    }];
    DHRadio *secondeRadio = [[DHRadio alloc]init];
    secondeRadio = _hotRadioArr[1];
    NSURL *url1 = [NSURL URLWithString:secondeRadio.coverimg];
    [_secondImageView sd_setImageWithURL:url1 placeholderImage:[UIImage imageNamed:@"zanwei"]];
    _secondImageView.tag = 10002;
   
    [_thirdImageView addGestureRecognizer:tap3];
    
    _thirdImageView.tag = 10003;
[_thirdImageView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(@5);
    make.bottom.equalTo(@-5);
    make.left.equalTo(_secondImageView.mas_right).offset(3);
    make.width.equalTo(@(heigth));
}];
    DHRadio *thirdRadio = [[DHRadio alloc]init];
    thirdRadio = _hotRadioArr[2];
    NSURL *url2 = [NSURL URLWithString:thirdRadio.coverimg];
    [_thirdImageView sd_setImageWithURL:url2 placeholderImage:[UIImage imageNamed:@"zanwei"]];
}
-(void)tapAction:(UITapGestureRecognizer *)tap{
    DHRadio *radio = [[DHRadio alloc]init];
    radio = _hotRadioArr[tap.view.tag-10001];
    [self.delegate pushToNextViewController:radio];
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
